package com.lizemin.inputoutput.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lzm
 * @date 2025/4/4 16:09
 * @description
 */
//@WebFilter("/*")
@Slf4j
public class LogFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        log.info("进入了过滤器");
        FixedResponseWrapper fixedResponseWrapper = new FixedResponseWrapper(response);
        FixedRequestWrapper fixedRequestWrapper = new FixedRequestWrapper(request);
        filterChain.doFilter(fixedRequestWrapper, fixedResponseWrapper);
        log.info("这是放行请求后的代码");
    }


}
